package com.itheima.springbootenable;


import com.itheima.config.EnableUser;
import com.itheima.config.UserConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import redis.clients.jedis.Jedis;


/**
 * @ComponentScan 扫描范围：当前引导类所在包及其子包
 *
 * com.itheima.springbootenable
 * com.itheima.config
 * //1.使用@ComponentScan扫描com.itheima.config包
 * //2.可以使用@Import注解，加载类。这些类都会被Spring创建，并放入IOC容器
 * //3.可以对Import注解进行封装。
 */


@SpringBootApplication
//@ComponentScan("com.itheima.config")
//@Import(UserConfig.class)
@EnableUser
public class SpringBootEnableApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(SpringBootEnableApplication.class,args);


//        //获取到bean
//        Object user = context.getBean("user");
//        System.out.println(user);


        Jedis jedis = context.getBean(Jedis.class);
        System.out.println(jedis);

        jedis.set("name","itheima");

        String name = jedis.get("name");
        System.out.println(name);
    }
}
